#include "ControlState.h"


ControlState::ControlState(std::shared_ptr<InputManager> inputManager) : _inputManager(inputManager), _updateInput(false) {}

ControlState::~ControlState(void)
{
}

bool ControlState::isKeyDown(unsigned int key, unsigned int player)
{
	if (!_updateInput)
		return false;
	
	if (_inputManager->isKeyDown(key))
		return true;
	else if (_inputManager->isJoystickBtnDown(key, player))
		return true;
	return false;
}

bool ControlState::isKeyPressed(unsigned int key, unsigned int player)
{
	if (!_updateInput)
		return false;

	if (_inputManager->isKeyPressed(key))
		return true;
	else if (_inputManager->isJoystickBtnPressed(key, player))
		return true;
	return false;
}

bool ControlState::isKeyReleased(unsigned int key, unsigned int player)
{
	if (!_updateInput)
		return false;

	if (_inputManager->isKeyReleased(key))
		return true;
	else if (_inputManager->isJoystickBtnDown(key, player))
		return true;
	return false;
}
